package com.study.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author ONE_LLX
 * @Description 全局异常处理Handler
 * @Date 14:34 2019/2/25
 * @Class GlobalExceptionHandler
 * @Version v1.0
 **/

@ControllerAdvice
@EnableWebMvc
public class GlobalExceptionHandler {

    /**
     * 全局异常处理配置
     * @param req
     * @param e
     * @return 异常处理后的json数据
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ErrorInfo ajaxException(HttpServletRequest req, Exception e){
       ErrorInfo errorInfo=new ErrorInfo(ErrorInfo.ERROR,"exception");
       return errorInfo;
    }


}
